package cn.tedu.xmfhlittlebird.controller;

import cn.tedu.xmfhlittlebird.pojo.dto.OrderListDTO;
import cn.tedu.xmfhlittlebird.pojo.dto.OrderMarkAddDTO;
import cn.tedu.xmfhlittlebird.pojo.vo.OrderDetailVO;
import cn.tedu.xmfhlittlebird.pojo.vo.OrderStandardListVO;
import cn.tedu.xmfhlittlebird.service.IOrderService;
import cn.tedu.xmfhlittlebird.web.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/order")
@Api(tags = "订单管理模块")
public class OrderController {

    @Autowired
    IOrderService orderService;

    @GetMapping("/standard")
    @ApiOperation("标准订单列表")
    public JsonResult<List<OrderStandardListVO>> standard(){
        List<OrderStandardListVO> standard = orderService.findStandard();
        return JsonResult.ok(standard);
    }

    @GetMapping("/{orderId}/detail")
    @ApiOperation("订单详情")
    public JsonResult<OrderDetailVO> findDetail(@PathVariable Long orderId){
        OrderDetailVO detail = orderService.findDetail(orderId);
        return JsonResult.ok(detail);
    }

    @PostMapping("/add/mark")
    @ApiOperation("添加订单备注")
    public JsonResult<Void> addMark(OrderMarkAddDTO orderMarkAddDTO){
        orderService.addMark(orderMarkAddDTO);
        return JsonResult.ok();
    }

    @GetMapping("/find/list")
    @ApiOperation("搜索订单列表")
    public JsonResult<List<OrderStandardListVO>> findList(OrderListDTO orderListDTO){
        List<OrderStandardListVO> list = orderService.findList(orderListDTO);
        return JsonResult.ok(list);
    }

    @GetMapping("/find/{status}/list")
    @ApiOperation("根据订单状态搜索订单列表")
    public JsonResult<List<OrderStandardListVO>> findListItem(@PathVariable Integer status){
        List<OrderStandardListVO> listItem = orderService.findListItem(status);
        return JsonResult.ok(listItem);
    }
}
